package com.webinsky.web.freemarker;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;

import java.io.*;

public class StaticSearchFreemarker extends StaticFreemarker {

    public StaticSearchFreemarker(Configuration cfg) {
        super(cfg);
    }

    @Override
    public void outputFile(File file) throws IOException, TemplateException {
        Writer out = null;
        try {
            out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
            Template temp = cfg.getTemplate("search.ftl", "UTF-8");
            temp.process(model, out);
        } catch (TemplateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}
